/**
 * ReportGear(2011)
 */
package com.reportgear.designer.editor.object;

import java.awt.BorderLayout;

import javax.swing.JTextField;

/**
 * 空对象编辑器
 * 
 * @version 1.0 2011-4-26
 * @author <a herf="lexloo@gmail.com">lexloo</a>
 * @since Report 1.0
 */
public class NoneEditor extends Editor {
	/**
	 * UID
	 */
	private static final long serialVersionUID = 2686352354751957214L;
	private JTextField textField;
	private String displayValue;

	public NoneEditor() {
		this(null);
	}

	public NoneEditor(String displyName, String name) {
		setLayout(new BorderLayout());
		this.displayValue = displyName;
		this.textField = new JTextField();
		add(this.textField, BorderLayout.CENTER);
		if (displyName != null) {
			this.textField.setText(displyName);
		}

		this.textField.setEditable(false);
		setName(name);
	}

	public NoneEditor(String displayName) {
		this(displayName, "");
	}

	public Object getValue() {
		return null;
	}

	public void setValue(Object value) {
		if (this.displayValue == null) {
			return;
		}
		this.textField.setText(this.displayValue);
		this.textField.setEditable(false);
	}

	public boolean accept(Object value) {
		return false;
	}
}